#ifndef UTORRENTAPI_H
#define UTORRENTAPI_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>

class UtorrentApi : public QObject
{
	Q_OBJECT

public:
	UtorrentApi(QObject *parent,QString serveur,QString port,QString user,QString password);
	~UtorrentApi();

	QString serveur;
	QString port;
	QString auth;

	void getList();
	void getSettings();
	void setSetting(QString parametre, QString valeur);

signals: 
	void resultReceive(QString request,QJsonDocument result);
	void errorReceive(QString demande,int statusCodeV,QNetworkReply::NetworkError error,QString errorString);

private:
	QNetworkAccessManager* nam;
	QString token;
	QStringList waiting;
	bool waitingToken;

	QString getToken();

	private slots:
		void finishedSlot(QNetworkReply* reply);
};

#endif // UTORRENTAPI_H
